﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CommonLib {
    public struct Matrix3 {
        public double[] v;
        public Matrix3(Vector3c x, Vector3c y, Vector3c z) {
            v = new double[9];

            v[0] = x.x;
            v[1] = y.x;
            v[2] = z.x;

            v[3] = x.y;
            v[4] = y.y;
            v[5] = z.y;

            v[6] = x.z;
            v[7] = y.z;
            v[8] = z.z;
        }
        // 0 1 2
        // 3 4 5
        // 6 7 8
        public Vector3c mul(Vector3c x) {
            Vector3c res = new Vector3c();

            res.x = v[0] * x.x + v[1] * x.y + v[2] * x.z;
            res.y = v[3] * x.x + v[4] * x.y + v[5] * x.z;
            res.z = v[6] * x.x + v[7] * x.y + v[8] * x.z;

            return res;
        }
        public void transpose() {
            double tmp;

            tmp = v[1];
            v[1] = v[3];
            v[3] = tmp;

            tmp = v[2];
            v[2] = v[6];
            v[6] = tmp;

            tmp = v[5];
            v[5] = v[7];
            v[7] = tmp;
        }
    }
}
